package com.hefei.hight.reflection;

import java.lang.reflect.Field;

/**
 * @author caizhengjun
 * @date 2020/9/5 10:51 上午
 */
public class Test {
    public static void main(String[] args) throws Exception {
        Class<?> clazz = Class.forName("com.hefei.hight.reflection.Person");
        Object person = clazz.newInstance();

        Field field = clazz.getDeclaredField("name");
        field.setAccessible(true);
        field.set(person, "caizhengjun");
        Object name = field.get(person);
        System.out.println(name);

    }
}
